<!DOCTYPE html>
<html lang="en">
<head>
  <title>浩然金融中心管理平台</title>
  <meta charset="utf-8">
  <meta content="width=device-width, initial-scale=1.0, user-scalable=0, minimum-scale=1.0, maximum-scale=1.0"
        name="viewport">
  <#include "/common/csslib.html">
</head>
<body>
<div class="main-wrapper">
  <!-- start: MAIN CONTAINER -->
  <div class="main-container inner">
    <!-- start: PAGE -->
    <div class="main-content">
      <div class="container">
        <div class="row h-home-path">
          <div class="col-md-12">
            <ol class="breadcrumb">
              <li><i class="fa fa-home"></i>&nbsp;&nbsp;所在位置</li>
              <li>首页</li>
              <li class="active">编辑数据条目信息</li>
            </ol>
          </div>
        </div>
        <div class="row h-main-search">
          <form action="javascript:;" method="post">
            <div class="pull-right h-btn-group">
              <button class="btn btn-info" id="return-btn" onclick="SystemDataEntryMgr.returnIndex()"><i
                      class="fa fa-mail-reply">&nbsp;&nbsp;</i>返回
              </button>
              <button class="btn btn-info" id="save" onclick="SystemDataEntryMgr.submitForm()" type="button"><i
                      class="fa fa-save">&nbsp;&nbsp;</i>保存
              </button>
            </div>
          </form>
        </div>

        <div class="form-horizontal  h-form-warp">
          <div class="h-msg-title h-table-header">
            <strong>数据条目信息<label style="color:red">(数据条目编码、数据条目类型都相同则不能重复录入)</label></strong>
          </div>
          <form action="/systemDataEntry/saveSystemDataEntry" class="form-horizontal" id="systemDataEntryForm"
                method="post" role="form">
            <input id="operation" name="operation" type="hidden" value="${operation!}"/>
            <input id="id" name="id" type="hidden" value="${systemDataEntry.id!}"/>
            <div class="form-group">
              <label class="col-sm-2 control-label">项目编码：</label>
              <div class="col-sm-6">
                <select class="col-sm-2" id="projectId" name="projectId">
                  <option value="">--请选择--</option>
                  <#list systemProjectInfoList as spl>
                  <#if (systemDataEntry.projectId!) == (spl.id!)>
                  <option selected="selected" value="${spl.id!}">${spl.projectCode!}</option>
                  <#else>
                  <option value="${spl.id!}">${spl.projectCode!}</option>
                </#if>
              </#list>
              </select>
            </div>
            <div class="col-sm-1">
              <span class="required">*</span>
            </div>
        </div>
        <div class="form-group">
          <label class="col-sm-2 control-label">数据条目编码：</label>
          <div class="col-sm-6">
            <input class="form-control" id="dataCode" name="dataCode" required="required" type="text"
                   value="${systemDataEntry.dataCode!}"/>
          </div>
          <div class="col-sm-1">
            <span class="required">*</span>
          </div>
        </div>
        <div class="form-group">
          <label class="col-sm-2 control-label">数据条目名称：</label>
          <div class="col-sm-6">
            <input class="form-control" id="dataName" name="dataName" required="required" type="text"
                   value="${systemDataEntry.dataName!}"/>
          </div>
          <div class="col-sm-1">
            <span class="required">*</span>
          </div>
        </div>
        <div class="form-group">
          <@PageDict dict_name="dataType" dict_desc="数据条目类型" dict_key="std_mysql_data_type"
          dict_value="${systemDataEntry.dataType!}"
          dict_type="select" label_class="col-sm-2 control-label text-right" dict_class="col-sm-6"
          required="required" />
        </div>
        <div class="form-group">
          <label class="col-sm-2 control-label">数据条目java编码：</label>
          <div class="col-sm-6">
            <input class="form-control" id="dataJavaCode" name="dataJavaCode" required="required"
                   type="text" value="${systemDataEntry.dataJavaCode!}"/>
          </div>
          <div class="col-sm-1">
            <span class="required">*</span>
          </div>
        </div>
        <div class="form-group">
          <@PageDict dict_name="dataJavaType" dict_desc="数据条目java类型" dict_key="std_data_java_type"
          dict_value="${systemDataEntry.dataJavaType!}"
          dict_type="select" label_class="col-sm-2 control-label text-right" dict_class="col-sm-6"
          required="required" />
        </div>
        <div class="form-group">
          <label class="col-sm-2 control-label">数据条目长度：</label>
          <div class="col-sm-6">
            <input class="form-control" digits="true" id="dataLength" name="dataLength"
                   required="required" type="text" value="${systemDataEntry.dataLength!}"/>
          </div>
          <div class="col-sm-1">
            <span class="required">*</span>
          </div>
        </div>
        <div class="form-group">
          <label class="col-sm-2 control-label">备注：</label>
          <div class="col-sm-6">
            <textarea class="col-sm-12" id="dataComment" name="dataComment" rows="70" style="height:100px">${systemDataEntry.dataComment!}</textarea>
          </div>
          <div class="col-sm-1">
            <span class="required">*</span>
          </div>
        </div>
        </form>
      </div>
    </div>
  </div>
  <!-- end: PAGE -->
</div>
<!-- end: MAIN CONTAINER -->
</div>
<#include "/common/jslib.html">
<!-- form页面js -->
<script type="text/javascript">
    $(function () {
        // 页面操作类型：add(添加)-edit(编辑)-view(查看)
        var operation = $("#operation").val();
        SystemDataEntryMgr = {
            // 初始化
            init: function () {
                // 查看的时候不显示保存按钮
                if (operation == "view") {
                    Jmts.setFormReadOnly();
                    $("#save").hide();
                }
                initDict(DICTURL, FORM, operation);
                initAmtAndRate();//初始化金额以及利率
            },
            // init end

            // 提交数据
            submitForm: function () {
                //提交之前校验数据条目是否已经存在（编码和数据类型都相同）
                var dataCode = $("#dataCode").val();
                var dataType = $("#dataType").val();
                var id = $("#id").val();
                var data = {
                    id: id,
                    dataCode: dataCode,
                    dataType: dataType
                }
                var url = "/systemDataEntry/checkDataEntry";
                Jmts.ajaxPost(url, data, function (result) {
                    if (result.success) {
                        Jmts.ajaxSubmit(document.getElementById("systemDataEntryForm"), function (result) {
                            var operation = result.operation;
                            if (result.success) {
                                Jmts.succTips(result.msg);
                                if (operation == 'add') {
                                    SystemDataEntryMgr.returnIndex();
                                } else if (operation == 'edit') {
                                    window.location.reload();
                                }
                            } else {
                                Jmts.errorTips(result.msg);
                            }
                        });
                    } else {
                        Jmts.warnTips(result.msg);
                    }
                })
                return false;
            },
            // submitForm end
            //返回
            returnIndex: function () {
                var projectId = $("#projectId").val();
                window.location.href = "/systemDataEntry/query?projectId=" + projectId;
            }
        };
        // 执行初始化
        SystemDataEntryMgr.init();
        // 前台验证表单
        $("#systemDataEntryForm").validate();
    });
</script>
</body>
</html>
